package com.itheima.boot.activemq.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.Destination;

@RestController
@RequestMapping(value = "/send")
public class SendMessageController {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate ;

    @Autowired
    private Destination queue ;

    @Autowired
    private Destination topic ;

    // 向点对点的队列发送消息
    @RequestMapping(value = "/queue")
    public void sendQueue(String text) {
        jmsMessagingTemplate.convertAndSend(queue , text);
    }

    // 向发布的订阅的队列发送消息
    @RequestMapping(value = "/topic")
    public void sendTopic(String text) {
        jmsMessagingTemplate.convertAndSend(topic , text);
    }

}
